//
//  ZJUserInfoTools.m
//  ZiJinLian
//
//  Created by lc on 2017/3/21.
//  Copyright © 2017年 lzy. All rights reserved.
//


#import "ZJBaseNavControllerViewController.h"

@implementation ZJUserDefaultsTools

//先保存

+(void)saveUserInfoLocal:(NSDictionary *)dic
{
    if (dic[DATA][MONEY] && ![dic[DATA][MONEY] isKindOfClass:[NSNull class]]) {
        [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][MONEY] forKey:MONEY];
    }
    
    if (dic[DATA][DEALER_GRADE] && ![dic[DATA][DEALER_GRADE] isKindOfClass:[NSNull class]]){
          [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][DEALER_GRADE] forKey:DEALER_GRADE];
    }
    if (dic[DATA][AVATAR] && ![dic[DATA][AVATAR] isKindOfClass:[NSNull class]]) {
       [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][AVATAR] forKey:AVATAR];
    }
    if (dic[DATA][USER_ID] && ![dic[DATA][USER_ID] isKindOfClass:[NSNull class]]) {
        [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][USER_ID] forKey:USER_ID];
    }
    if (dic[DATA][TOKEN] && ![dic[DATA][TOKEN] isKindOfClass:[NSNull class]]) {
      [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][TOKEN] forKey:TOKEN];
    }
    if (dic[DATA][NICK_NAME] && ![dic[DATA][NICK_NAME] isKindOfClass:[NSNull class]]) {
           [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][NICK_NAME] forKey:NICK_NAME];
    }
    if (dic[DATA][GENDER] && ![dic[DATA][GENDER] isKindOfClass:[NSNull class]]) {
            [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][GENDER] forKey:GENDER];
    }
    if (dic[DATA][PHONE] && ![dic[DATA][PHONE] isKindOfClass:[NSNull class]]) {
        [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][PHONE] forKey:PHONE];
    }
    if (dic[DATA][IMNAME] && ![dic[DATA][IMNAME] isKindOfClass:[NSNull class]]) {
        [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][IMNAME] forKey:IMNAME];
    }
    if (dic[DATA][IMPASSWORD] && ![dic[DATA][IMPASSWORD] isKindOfClass:[NSNull class]]) {
        [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][IMPASSWORD] forKey:IMPASSWORD];
    }
    if (dic[DATA][WECHATBIND] && ![dic[DATA][WECHATBIND] isKindOfClass:[NSNull class]]) {
        [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][WECHATBIND] forKey:WECHATBIND];
    }
    if (dic[DATA][QQBIND] && ![dic[DATA][QQBIND] isKindOfClass:[NSNull class]]) {
        [[NSUserDefaults standardUserDefaults] setObject:dic[DATA][QQBIND] forKey:QQBIND];
    }

    [[NSUserDefaults standardUserDefaults] synchronize];
}



+(BOOL)isLogin{
    return [[NSUserDefaults standardUserDefaults] objectForKey:USER_ID]!=nil;
}
+(BOOL)isWeChatBind{
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:WECHATBIND]intValue]==1) {
        return YES;
    }else{
        return NO;
    }
}
+(BOOL)isQQBind{
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:QQBIND]intValue]==1) {
        return YES;
    }else{
        return NO;
    }
}
+(NSString *)getCurrentUserID{
    return [[NSUserDefaults standardUserDefaults]objectForKey:USER_ID];
}
+(NSString *)getCurrentUserPhone{
    return [[NSUserDefaults standardUserDefaults]objectForKey:PHONE];
}
+(NSString*)getCurrentIMName{
    return [[NSUserDefaults standardUserDefaults]objectForKey:IMNAME];
}
+(NSString*)getCurrentIMPASSWORD{
    return [[NSUserDefaults standardUserDefaults]objectForKey:IMPASSWORD];
}
+(NSString *)getCurrentUserToken{
  return [[NSUserDefaults standardUserDefaults]objectForKey:TOKEN];
}

+(NSString*)getAvatar{
    return [[NSUserDefaults standardUserDefaults]objectForKey:AVATAR];
}

+(void)clearWithoutAvatar{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:ISLOGIN];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:MONEY];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:USER_ID];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:TOKEN];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:NICK_NAME];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:GENDER];
}
+(NSString *)getCurrentNickName{

  return [[NSUserDefaults standardUserDefaults]objectForKey:NICK_NAME];
}



@end
